package com.rivulet.doj_backend.mapper;

import com.rivulet.doj_backend.pojo.Message;
import com.rivulet.doj_backend.pojo.Question;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

@Component
public interface MessageMapper {
    @Select("select * from t_message where message_id = #{message_id}")
    public Message getMessageByMessageId(@Param("message_id")Integer message_id);

    @Insert("insert into t_message (message_id,message_range,message_content,publisher_id,relation_class_id) values (#{message_id},#{message_range},#{message_content},#{publisher_id},#{relation_class_id})")
    public void addMessage(@Param("message_id")Integer message_id,@Param("message_range")Integer message_range,@Param("message_content")String message_content,@Param("publisher_id")Integer publisher_id,@Param("relation_class_id")Integer relation_class_id);

    @Insert("insert into t_user_join_class (class_id,user_id) values (#{class_id},#{user_id})")
    public void setUserJoinClass(@Param("user_id")Integer user_id,@Param("class_id")Integer class_id);

    @Select("select * from t_message where competition_id = #{competition_id}")
    public Message competitionMessage(Integer user_id, @Param("competition_id") Integer competition_id);

    @Insert({"insert  t_message (message_id,message_range,message_content,publisher_id) values (#{message_id},#{message_range},#{message_content},#{publisher_id})"})
    public void addAllMessage(@Param("message_id") Integer message_id, @Param("message_range") Integer message_range, @Param("message_content") String message_content, @Param("publisher_id") Integer publisher_id);

}
